package io.renren.vo;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.annotation.TableId;
import io.renren.entity.SeatEntity;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 会议室
 *
 * @author 1
 * @email 1@2.com
 * @date 2021-08-19 11:56:03
 */
@Data
public class SeatVo {
    /**
     *
     */
    @TableId
    private Long id;
    /**
     * 工位编号
     */
    private String code;
    /**
     * 工位名称
     */
    private String name;
    /**
     * 工位所属的企业id
     */
    private String compId;
    /**
     * 城市
     */
    private String city;
    /**
     * 工位楼层
     */
    private String floor;
    /**
     * 工位类型。fixed-固定；share-共享
     */
    private String type;
    /**
     * 工位类型名称
     */
    private String typeName;
    /**
     * 工位状态 unusable表示维修 usable表示可用
     */
    private String state;
    /**
     * AP mac
     */
    private String apMac;
    /**
     * 价签id
     */
    private String eslId;
    /**
     * 省份
     */
    private String province;
    /**
     * 省份名称
     */
    private String provinceName;
    /**
     * 城市名称
     */
    private String cityName;
    /**
     * 办公区名称
     */
    private String floorName;
    /**
     * 预定工位的员工id
     */
    private String department;
    /**
     * 邮箱
     */
    private String email;

    private String userId;

    private String workTarget;

    /**
     * 是否党员
     */
    private Boolean isPartyMember;

    public static SeatVo convertFor(SeatEntity seatEntity) {
        SeatVo vo = new SeatVo();
        if (seatEntity != null) {
            BeanUtils.copyProperties(seatEntity, vo);
            String typeName = "固定";
            if ("share".equals(seatEntity.getType())) {
                typeName = "共享";
            }
            vo.setTypeName(typeName);
        }
        return vo;
    }

    public static List<SeatVo> convertFor(List<SeatEntity> seatEntitys) {
        List<SeatVo> vos = new ArrayList<>();
        if (CollectionUtil.isNotEmpty(seatEntitys)) {
            for (SeatEntity seatEntity : seatEntitys) {
                vos.add(convertFor(seatEntity));
            }
        }
        return vos;
    }

}
